package com.shyroke.common;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class CommonUtils {

	/**
	 * 得到List中不重复的元素并组成新的List
	 * @param wenjianjiaList1
	 * @return
	 */
	public static List<String> getNoRepetition(List<String> wenjianjiaList1) {
		
		 Set<String> set = new  HashSet<String>(); 
         List<String> newList = new  ArrayList<String>(); 
         for (String cd:wenjianjiaList1) {
            if(set.add(cd)){
                newList.add(cd);
            }
        }
		
		return newList;
	}

	/**
	 * 获得6位随机验证码
	 * @return
	 */
	public static int getCode() {
		 int randNum = 1 + (int)(Math.random() * ((999999 - 1) + 1));
		    return randNum;
	}

	/**
	 * 判断是否只是txt文件
	 * @param originName
	 * @return 
	 */
	public static boolean isTxtFile(String originName) {
		
		String suff = originName.substring(originName.indexOf(".")+1, originName.length());
		
		return suff.equals("txt")?true:false;
	}
	
	

}
